angular.module('information', [])
    .controller('informationCtrl', ['$scope', '$state', '$localStorage', 'cities', '$rootScope', function($scope, $state, $localStorage, cities, $rootScope) {

        $scope.cities = cities.get();
        $scope.nowtoken = $localStorage.mutian_token;

        if ($scope.service.square || $scope.service.square == 0) {
            if(user) {
                angular.merge($scope.service, {
                    name: user.real_name,
                    tel: parseInt(user.tel),
                    email: user.email,
                });
            }
        } else {
            window.history.go(-1);
        }

        $scope.issub = false;
        $scope.goAppointment = function(bool, service) {
            if (!bool) {
                $state.go('reservation.appointment');
            } else {
                $scope.issub = true;
            }
        };

        $scope.$on('$stateChangeSuccess', function(event, toState, toParams, fromState, fromParams) {
            if (toState.name == 'reservation.information') {
                $rootScope.step = 2;
            }
        });

        $scope.goBackDemand = function() {
            window.history.go(-1);
        };

    }])
